extends Node2D
class_name Points
var point := preload("res://Board/scene/point.tscn")

signal select_grid_signal(Point)

func _ready() -> void:
	loadPoints()

func loadPoints() -> void:
	var map_x:int = BoardCommon.map_size.x
	var map_y:int = BoardCommon.map_size.y
	
	for linex in range(0,map_x+1):
		for liney in range(0,map_y+1):
			if liney==5: continue
			var pointInstance:Point=point.instantiate()
			add_child(pointInstance)
			pointInstance.position.y+=BoardCommon.unit_size.y*liney
			pointInstance.position.x+=BoardCommon.unit_size.x*linex
			pointInstance.grid_pos=Vector2i(linex,liney-1 if liney >=5 else liney)
			#链接信号
			pointInstance.click_point_signal.connect(click_point)

@warning_ignore("shadowed_variable")
func click_point(point:Point) -> void: select_grid_signal.emit(point)
